import React from 'react';
import { Popconfirm } from 'antd';
import { ActionItem } from '../../../typings'

export type DeleteButtonProps = ActionItem & {
  itemClass?: string;
  needDisabled?: boolean;
  value: string;
  item: any;
  componentProps: {
    getTitle: (item: any) => string;
  };
};

export const DeleteButton: React.FC<DeleteButtonProps> = (props) => {
  const { label, itemClass, handler, value, item, componentProps } = props;
  const title = componentProps.getTitle(item);

  return (
    <Popconfirm title={title} onConfirm={handler} placement="topRight">
      <a className={itemClass} key={label}>
        {label}
      </a>
    </Popconfirm>
  );
};
